package com.demo03_feed.service;

import com.demo03_feed.client.InteractionServiceClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class FollowerService {
    
    private final InteractionServiceClient interactionServiceClient;
    
    // 通过Feign调用interaction-service获取粉丝列表
    public List<Long> getFollowerIds(Long authorId) {
        // 调用interaction-service获取真实的粉丝列表
        log.info("获取作者[{}]的粉丝列表", authorId);
        try {
            List<Long> followerIds = interactionServiceClient.getFollowerIds(authorId);
            log.info("成功获取作者[{}]的粉丝列表，共{}位粉丝", authorId, followerIds.size());
            return followerIds;
        } catch (Exception e) {
            log.error("获取作者[{}]的粉丝列表失败: {}", authorId, e.getMessage(), e);
            throw e;
        }
    }
}